//
//  LawTableViewCell.m
//  PropertyManager
//
//  Created by TNG on 2018/8/1.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "LawTableViewCell.h"

@implementation LawTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.separatorInset = UIEdgeInsetsMake(0, 15, 0, 0);
    }
    return self;
}

-(void)creatUI{
    [self.contentView addSubview:self.img];
    [self.contentView addSubview:self.titieLabel];
    [self.contentView addSubview:self.detailLabel];
}

-(UIImageView *)img
{
    if (_img == nil) {
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 110, 67)];
        _img.contentMode = UIViewContentModeScaleToFill;
    }
    return _img;
}

-(UILabel *)titieLabel
{
    if (_titieLabel == nil) {
        _titieLabel = [[UILabel alloc] initWithFrame:CGRectMake(135, 10, WIDTH - 145, 20)];
        _titieLabel.font = font(16);
        _titieLabel.textColor = SFM51;
        _titieLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _titieLabel;
}

-(UILabel *)detailLabel
{
    if (_detailLabel == nil) {
        _detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(135, 38, WIDTH - 145, 34)];
        _detailLabel.font = font(12);
        _detailLabel.textColor = SFM153;
        _detailLabel.textAlignment = NSTextAlignmentLeft;
        _detailLabel.numberOfLines = 0;
    }
    return _detailLabel;
}

-(void)send
{
    self.img.backgroundColor = SFMRandColor;
    self.titieLabel.text = @"我是标题七个字";
    self.detailLabel.text = @"如果你无法简洁的表达你的想法，那只说明你还不够了解它。只说明你还不够了解它。";
}

-(void)sendLawModel:(LawModel *)model
{
    WeakSelf;
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        weakSelf.img.image = image;
    }];
    self.titieLabel.text = model.title;
    self.detailLabel.text = [NSString filterHTML:model.content];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
